package net.wwang.demo.config.security;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: demo
 * @BelongsPackage: net.wwang.demo.config.security
 * @Author: WangWei
 * @CreateTime: 2020-06-18 16:39
 * @Description:
 */
@Component
public class MyPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence charSequence) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        String encode = encoder.encode(charSequence);
        //加密方法可以根据自己的需要修改
        return encode;
    }

    @Override
    public boolean matches(CharSequence charSequence, String s) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        return encoder.matches(charSequence, s);
    }
}
